home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cug172 / integ.c < prev    next >
C/C++ Source or Header  |  1986-02-05  |  1KB  |  41 lines

  1. /*
  2.   HEADER: CUG     nnn.nn;
  3.   TITLE:     LEX - A Lexical Analyser Generator
  4.   VERSION:     1.0 for IBM-PC
  5.   DATE:      Jan 30, 1985
  6.   DESCRIPTION:     A Lexical Analyser Generator. From UNIX
  7.   KEYWORDS:     Lexical Analyser Generator YACC C PREP
  8.   SYSTEM:     IBM-PC and Compatiables
  9.   FILENAME:      INTEG.C
  10.   WARNINGS:     This program is not for the casual user. It will
  11.          be useful primarily to expert developers.
  12.   CRC:         N/A
  13.   SEE-ALSO:     YACC and PREP
  14.   AUTHORS:     Scott Guthery 11100 leafwood lane Austin, TX 78750
  15.   COMPILERS:     DESMET-C
  16.   REFERENCES:     UNIX Systems Manuals
  17. */
  18. /*
  19.  * integ -- ascii to long (various bases)
  20.  */
  21. long
  22. integ(cp, base)
  23. char *cp;
  24. register base;
  25. {
  26.         register c;
  27.         long n;
  28.  
  29.         n = 0;
  30.         while (c = *cp++) {
  31.                 if (c>='A' && c<='Z')
  32.                         c += 'a'-'A';
  33.                 if (c>='a' && c<='z')
  34.                         c = (c-'a')+10+'0';
  35.                 if (c < '0' || c > base+'0')
  36.                         break;
  37.                 n = n*base + c-'0';
  38.         }
  39.         return(n);
  40. }
  41.